package com.zige.zige.utils;

import android.annotation.SuppressLint;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Kim on 2015/11/25.
 */
public class DateUtils {

    /**将时间戳转换成具体的时间*/
    public static String timeStampToDate(String date){


        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String sd = sdf.format(new Date(Long.parseLong(date)));

        return sd;
    }
    /**将时间戳转换成具体的时间*/
    public static String timeStampToDated(String date){


        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

        String sd = sdf.format(new Date(Long.parseLong(date)));

        return sd;
    }



    /*时间戳转换成字符窜*/
    public static String getDateDay(String time) {
        Date date = new Date(Long.parseLong(time));
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int day = calendar.get(Calendar.DAY_OF_MONTH);

        return String.valueOf(day);
    }
    public static String getDateMonth(String time) {
        Date date = new Date(Long.parseLong(time));
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int day = calendar.get(Calendar.MONTH)+1;

        return String.valueOf(day);
    }

    /**获取当前时间*/
    public static String getNowDate(){
        SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
        Date date = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(date);

        return str;
    }



    public static String getDateDayAcount(String time){

        return null;
    }

    /**时间转成时间戳*/
    private static String timeStemp;

    public static String getTime(String user_time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
        try {

            SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd");
            Date date=simpleDateFormat .parse(user_time);
             timeStemp = String.valueOf(date.getTime());

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return timeStemp;
    }
    public static String getNowTimeStamp(){

        long time = System.currentTimeMillis()/1000;

        return String.valueOf(time);
    }

    /**
     * 获取系统当前时间
     *
     * @version 1.0
     * @createTime 2015年1月30日,下午1:50:53
     * @updateTime 2015年1月30日,下午1:50:53
     * @createAuthor WangYuWen
     * @updateAuthor WangYuWen
     * @updateInfo (此处输入修改内容,若无修改可不写.)
     *
     * @return
     */
    @SuppressLint("SimpleDateFormat")
    public static String getDate() {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    /**
     *
     * 获取系统当前日期
     *
     * @version 1.0
     * @createTime 2015年3月10日,下午3:40:49
     * @updateTime 2015年3月10日,下午3:40:49
     * @createAuthor WangYuWen
     * @updateAuthor WangYuWen
     * @updateInfo (此处输入修改内容,若无修改可不写.)
     *
     @SuppressLint("SimpleDateFormat")
      * @return
     */
    public static String getDay() {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(currentTime);
        return dateString;
    }



}
